const http = require('http')


let options = {
  host: 'localhost',
  port: 1234,
  path: '/?a=1',
  method: 'POST'
}


//处理跨域问题 在请求外部添加服务
const server = http.createServer((request, response) => {
  let req = http.request(options, (res) => {
    let arr = []
    res.on('data', (data) => {
      arr.push(data)
    })
    res.on('end', () => {
      const ret = Buffer.concat(arr).toString()
      // response.setHeader("Content-type","application/json")
      console.log(ret);
      response.write(ret)
      // response.end(ret)
    })
  })
  req.end('拉勾教育')
})

// req.end('{"name":"lg"}')
// req.end('a=1&b=2')

server.listen(2345, () => {
  console.log('本地服务启动了')
})